package com.myapp.model;

import java.io.Serializable;
import java.util.Date;
import javax.jdo.annotations.*;

import com.google.appengine.api.users.User;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Query(name="latestPropertyValues",
       value="select from com.myapp.model.PropertyValue order by date desc range 0,5")
public class PropertyValue implements Serializable
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private User associatedUser;

    @Persistent(nullValue = NullValue.EXCEPTION)
    private Property property;

    @Persistent(nullValue = NullValue.EXCEPTION)
    private ValueObject valueObject;
        	
    @Persistent(nullValue = NullValue.EXCEPTION)
    private Date date;

    public PropertyValue(User associatedUser, Property property, ValueObject valueObject, Date date) {
        this.associatedUser = associatedUser;
        this.property = property;
        this.valueObject = valueObject;
        this.date = date;
    }

    public Long getId() {
        return id;
    }

    public User getAssociatedUser() {
        return associatedUser;
    }

    public Property getProperty() {
        return property;
    }

    public ValueObject getValueObject() {
        return valueObject;
    }

    public Date getDate() {
        return date;
    }
}
